<%@page contentType="text/html;charset=utf-8" pageEncoding="UTF-8" %>
<%@taglib prefix="h" uri="http://struts.apache.org/tags-html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="b" uri="http://struts.apache.org/tags-bean" %>


<h1><%=request.getSession().getAttribute("title")%></h1>
<div>
    <h:form action="/protected/user?method=${param['method']}">
        <table border="0">
            <tr>
                <td><b:message key="user_firstName"/></td>
                <td><h:text property="name" maxlength="512"/><span class="error" ><h:errors property="name" /></span></td>
            </tr>
            <tr>
                <td><b:message key="user_lastName"/></td>
                <td><h:text property="surname" maxlength="512"/><span class="error" ><h:errors property="surname" /></span></td>
            </tr>
            <c:if test="${param['method'] == 'showCreateUserForm'}">
                <tr>
                    <td><span class="important"><b:message key="user_username"/></span></td>
                    <td><h:text property="username"/><span class="error" ><h:errors property="username" /></span></td>
                </tr> 
            </c:if>

            <c:if test="${param['method'] == 'showUpdateUserForm'}">
                <tr>
                    <td><b:message key="user_username"/></td>
                    <td><h:text property="username" disabled="true" maxlength="512"/><span class="error" ><h:errors property="username" /></span></td>
                </tr> 
            </c:if>
            <!--
            <c:if test="${param['method'] == 'showUpdateUserForm'}">
                <tr>
                    <td> Old password</td>
                    <td><h:password property="oldPassword" maxlength="512"/></td>
                </tr>
            </c:if>
            -->
            <tr>
                <td><b:message key="user_password"/></td>
                <td><h:password property="password" maxlength="512"/><span class="error" ><h:errors property="password" /></span></td>
            </tr>
            <tr>
                <td><b:message key="user_repeatPasswod"/></td>
                <td><h:password property="password2" maxlength="512"/><span class="error" ><h:errors property="password2" /></span></td>
            </tr>
            <tr>
                <td><b:message key="user_type"/></td>
                <td>
                    <h:radio property="type" value="3"/><b:message key="user_type_admin"/><br>
                    <h:radio property="type" value="2"/><b:message key="user_type_normal"/><br>
                    <h:radio property="type" value="1"/><b:message key="user_type_guest"/><br>
                    <span class="error" ><h:errors property="type" /></span>
                </td>
            </tr>
           

        </table>
        <c:if test="${param['method'] == 'showCreateUserForm'}">
            <h:submit property="submit"><b:message key="gen_create"/></h:submit>
        </c:if>

        <c:if test="${param['method'] == 'showUpdateUserForm'}">
            <h:submit property="submit"><b:message key="gen_update"/></h:submit>
        </c:if>

        <h:cancel><b:message key="gen_cancel"/></h:cancel>
    </h:form>
</div>
